package com.chixing.day20_annotation_jdk8;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class StreamDemo {
    public static void main(String[] args) {
        List<Integer> lists = new ArrayList<>();
        lists.add(1);
        lists.add(null);
        lists.add(3);
        lists.add(4);
        lists.add(null);
        lists.add(6);

        lists.stream().filter(list -> list != null).forEach(System.out::println);

        List<Integer> costBeforeTax2 = Arrays.asList(100, 200, 300, 400, 500);
        costBeforeTax2.stream()
                .map((cost) -> cost + 0.12*cost)
                .forEach(System.out::println);

        double num = costBeforeTax2.stream()
                    .limit(5)
                    .map((cost) ->cost + 0.12*cost)
                    .reduce((sum,cost) ->sum + cost)
                    .get();

        System.out.println(num);

        System.out.println("sss");

    }
}
